﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using FluentRibbon.Definitions;
using FluentRibbon.Definitions.Controls;
using QASPRibbon;
using QASPRibbon.Controls;
using QASPRibbon.Libraries;
using ImageDefinition = QASPRibbon.Controls.ImageDefinition;

namespace QASPRibbonDemo.VisualWebPart1
{
    [ToolboxItemAttribute(false)]
    public class VisualWebPart1 : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/QASPRibbonDemo/VisualWebPart1/VisualWebPart1UserControl.ascx";

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
            var ribbonAdapter = RibbonController.Current;
            //var tab = new RibbonTab
            //              {
            //                  Id = "QuantumArtTab",
            //                  Title = "Quantum Art",
            //                  Groups = new[]
            //                               {
            //                                   new RibbonGroup
            //                                       {
            //                                           Id = "Group2",
            //                                           Title = "Group 2",
            //                                           Template = GroupTemplateLibrary.SimpleTemplate,
            //                                           Controls=new RibbonControl[]
            //                                                        {
            //                                                              new RibbonButton("Button1","ClickMe!")
            //                                                                {
            //                                                                    Image = ImageLibrary.GetStandardImage(0,0)
            //                                                                },
            //                                                              new RibbonButton("Button2","ClickMe2!")
            //                                                                {
            //                                                                    Image = ImageLibrary.GetStandardImage(2,0)
            //                                                                },
            //                                                              new RibbonButton("Button2","ClickMe3!")
            //                                                                {
            //                                                                    Image = ImageLibrary.GetStandardImage(1,0)
            //                                                                },
            //                                                                  new RibbonFlyoutAnchor
            //                                                                      {
            //                                                                          Id="FO1", Title = "FlyOut", DisplayMode = RibbonMenuDisplayMode.Menu32, Image = ImageLibrary.GetStandardImage(5,5),
            //                                                                          Sections = new List<RibbonMenuSection>
            //                                                                                         {
            //                                                                                             new RibbonMenuSection("RMS1", "Section 1")
            //                                                                                                 {
            //                                                                                                     DisplayMode = RibbonMenuDisplayMode.Menu16,
            //                                                                                                     TemplateAlias = "o1",
            //                                                                                                     Controls = new List<RibbonControl>
            //                                                                                                    {
            //                                                                                                        new RibbonButton("FO1B1","YEP!"){CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true", Image = ImageLibrary.GetStandardImage(8,8)},
            //                                                                                                        new RibbonButton("FO1B2","YEP2!"){CommandJavaScript = "alert('2');", CommandEnableJavaScript = "true", Image = ImageLibrary.GetStandardImage(7,7)}
            //                                                                                                    }
            //                                                                                                 }
            //                                                                                         }
            //                                                                      }
            //                                                        }
            //                                       },
            //                                   new RibbonGroup
            //                                       {
            //                                           Id = "Group1",
            //                                           Title = "Group 1",
            //                                           Template = GroupTemplateLibrary.SimpleTemplate,
            //                                           Controls = new RibbonControl[]
            //                                                          {
            //                                                              //new RibbonDropDown("DD1", "DropDown")
            //                                                              //    {
            //                                                              //        Width = 300,
            //                                                              //        InitialValueJavaScript = "return true;",
            //                                                              //        Sections = new List<RibbonMenuSection>
            //                                                              //                       {
            //                                                              //                          new RibbonMenuSection("CaptionOnly", "CaptionOnly")
            //                                                              //                          {
            //                                                              //                              DisplayMode = RibbonMenuDisplayMode.Menu32,
            //                                                              //                              Controls = new List<RibbonControl>
            //                                                              //                                      {
            //                                                              //                                          new RibbonButton("B125", "B125"){Image = ImageLibrary.GetStandardImage(4,2), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B126", "B126"){Image = ImageLibrary.GetStandardImage(5,2), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B127", "B127"){Image = ImageLibrary.GetStandardImage(6,2), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B128", "B128"){Image = ImageLibrary.GetStandardImage(7,2), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonFlyoutAnchor
            //                                                              //                                              {
            //                                                              //                                                  Id="FO2", Title = "FlyOut2", 
            //                                                              //                                                  DisplayMode = RibbonMenuDisplayMode.Menu32, 
            //                                                              //                                                  Image = ImageLibrary.GetStandardImage(5,5), 
            //                                                              //                                                  Sections = new List<RibbonMenuSection>
            //                                                              //                                                                  {
            //                                                              //                                                                      new RibbonMenuSection("RMS12", "Section 12")
            //                                                              //                                                                          {
            //                                                              //                                                                              DisplayMode = RibbonMenuDisplayMode.Menu32,
            //                                                              //                                                                              Controls = new List<RibbonControl>
            //                                                              //                                                                              {
            //                                                              //                                                                                  new RibbonButton("FO1B12","YEP!2"){CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true", Image = ImageLibrary.GetStandardImage(8,8)},
            //                                                              //                                                                                  new RibbonButton("FO1B22","YEP22!"){CommandJavaScript = "alert('2');", CommandEnableJavaScript = "true", Image = ImageLibrary.GetStandardImage(7,7)}
            //                                                              //                                                                              }
            //                                                              //                                                                          }
            //                                                              //                                                                  }
            //                                                              //                                              }
            //                                                              //                                      }
            //                                                              //                          },
            //                                                              //                          new RibbonMenuSection("Image16AndCaption", "Image16AndCaption")
            //                                                              //                          {
            //                                                              //                              DisplayMode = RibbonMenuDisplayMode.Menu,
            //                                                              //                              Controls = new List<RibbonControl>
            //                                                              //                                      {
            //                                                              //                                          new RibbonButton("B155", "B155"){Image = ImageLibrary.GetStandardImage(4,1), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B156", "B156"){Image = ImageLibrary.GetStandardImage(5,1), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B157", "B157"){Image = ImageLibrary.GetStandardImage(6,1), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B158", "B158"){Image = ImageLibrary.GetStandardImage(7,1), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"}
            //                                                              //                                      }
            //                                                              //                          },
            //                                                              //                          new RibbonMenuSection("Image32AndCaption", "Image32AndCaption")
            //                                                              //                          {
            //                                                              //                              DisplayMode = RibbonMenuDisplayMode.Menu16,
            //                                                              //                              Controls = new List<RibbonControl>
            //                                                              //                                      {
            //                                                              //                                          new RibbonButton("B551", "B551"){Image = ImageLibrary.GetStandardImage(0,0), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B552", "B552"){Image = ImageLibrary.GetStandardImage(1,0), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B553", "B553"){Image = ImageLibrary.GetStandardImage(2,0), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"},
            //                                                              //                                          new RibbonButton("B554", "B554"){Image = ImageLibrary.GetStandardImage(3,0), CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"}
            //                                                              //                                      }
            //                                                              //                          }
            //                                                              //                       }
            //                                                              //    },
            //                                                              //new RibbonDropDown("DD2", "DropDown2")
            //                                                              //    {
            //                                                              //        Width = 300,
            //                                                              //        DisplayMode = RibbonMenuDisplayMode.Menu16,
            //                                                              //        InitialValueJavaScript = "return true;",
            //                                                              //        Sections = new List<RibbonMenuSection>
            //                                                              //                       {
            //                                                              //                           new RibbonMenuSection("CaptionOnly", "CaptionOnly")
            //                                                              //                               {
            //                                                              //                                   Controls = new List<RibbonControl>
            //                                                              //                                           {
            //                                                              //                                               new RibbonButton("B1", "1"){CommandJavaScript = "alert('1');", CommandEnableJavaScript = "true"}
            //                                                              //                                           }
            //                                                              //                               }
            //                                                              //                       }
            //                                                              //    },
            //                                                                  new RibbonFlyoutAnchor("Gallery","Gallery")
            //                                                                      {
            //                                                                         DisplayMode = RibbonMenuDisplayMode.Menu32, 
            //                                                                                                                Image = ImageLibrary.GetStandardImage(5,5), 
            //                                                                                                                Sections = new List<RibbonMenuSection>
            //                                                                                                                                {
            //                                                                                                                                    new RibbonMenuSection("RMS12", "Section 12")
            //                                                                                                                                        {
            //                                                                                                                                            Controls = new List<RibbonControl>
            //                                                                                                                                                           {
            //                                                                                                                                                               new RibbonGallery("GalleryFirst", "Quantum Art Gallery")
            //                                                                                                                                                                   {
            //                                                                                                                                                                       ElementDimensions = RibbonGalleryElementSize.Size96by72,
            //                                                                                                                                                                       Width = 20,
            //                                                                                                                                                                       Controls = new List<RibbonControl>
            //                                                                                                                                                                                      {
            //                                                                                                                                                                                          new RibbonGalleryButton("GalleryFirstB1","B1"){ImageUrl = "/_layouts/images/gallery/1.jpg", ElementDimensions = RibbonGalleryElementSize.Size96by72},
            //                                                                                                                                                                                          new RibbonGalleryButton("GalleryFirstB2","B2"){ImageUrl = "/_layouts/images/gallery/2.jpg", ElementDimensions = RibbonGalleryElementSize.Size96by72},
            //                                                                                                                                                                                          new RibbonGalleryButton("GalleryFirstB3","B3"){ImageUrl = "/_layouts/images/gallery/3.jpg", ElementDimensions = RibbonGalleryElementSize.Size96by72},
            //                                                                                                                                                                                          new RibbonGalleryButton("GalleryFirstB4","B4"){ImageUrl = "/_layouts/images/gallery/4.jpg", ElementDimensions = RibbonGalleryElementSize.Size96by72},
            //                                                                                                                                                                                          new RibbonGalleryButton("GalleryFirstB5","B5"){ImageUrl = "/_layouts/images/gallery/5.jpg", ElementDimensions = RibbonGalleryElementSize.Size96by72},
            //                                                                                                                                                                                          new RibbonGalleryButton("GalleryFirstB6","B6"){ImageUrl = "/_layouts/images/gallery/6.jpg", ElementDimensions = RibbonGalleryElementSize.Size96by72}
            //                                                                                                                                                                                      }
            //                                                                                                                                                                   }
            //                                                                                                                                                           }
            //                                                                                                                                        }
            //                                                                                                                                }
            //                                                                      }
            //                                                          }
            //                                       }
            //                               }
            //              };
            var tab = new RibbonTab("Tab1", "Quantum Art")
                          {
                              GroupTemplates = GroupTemplateLibrary.AllTemplates,
                              Groups = new RibbonControlsCollection<RibbonGroup>
                                           {
                                               new RibbonGroup("Group1", "Tasks")
                                                   {
                                                       Template = GroupTemplateLibrary.ThreeRow,
                                                       Controls = new RibbonControl[]
                                                                      {
                                                                          new RibbonButton("Button1", "New Task")
                                                                              {
                                                                                  Image = ImageLibrary.GetStandardImage(5, 5),
                                                                                  CommandEnableJavaScript = "true;",
                                                                                  CommandJavaScript =
                                                                                      "alert('Create Task');"
                                                                              },
                                                                              new RibbonDropDown("DD2", "DropDown2")
                                                                              {
                                                                                  Width = 100, Title = "Make your choose",
                                                                                  InitialValueJavaScript = "return true;",
                                                                                  Sections = new List<RibbonMenuSection>
                                                                                                 {
                                                                                                     new RibbonMenuSection("SharePoint", "Microsoft SharePoint")
                                                                                                         {
                                                                                                             DisplayMode = RibbonDisplayMode.Menu,
                                                                                                             Controls = new List<RibbonControl>
                                                                                                                     {
                                                                                                                         new RibbonButton("2003", "SharePoint 2003")
                                                                                                                         {
                                                                                                                             CommandJavaScript = "alert('SharePoint 2003');",
                                                                                                                             CommandEnableJavaScript = "true"
                                                                                                                         },
                                                                                                                         new RibbonButton("2007", "SharePoint 2007")
                                                                                                                         {
                                                                                                                             CommandJavaScript = "alert('SharePoint 2007');",
                                                                                                                             CommandEnableJavaScript = "true"
                                                                                                                         },
                                                                                                                         new RibbonButton("2010", "SharePoint 2010")
                                                                                                                         {
                                                                                                                             CommandJavaScript = "alert('SharePoint 2010');",
                                                                                                                             CommandEnableJavaScript = "true"
                                                                                                                         },
                                                                                                                         new RibbonButton("2013", "SharePoint 2013")
                                                                                                                         {
                                                                                                                             CommandJavaScript = "alert('SharePoint 2013');",
                                                                                                                             CommandEnableJavaScript = "true"
                                                                                                                         }
                                                                                                                     }
                                                                                                         },
                                                                                                         new RibbonMenuSection("Windows", "Microsoft Widows")
                                                                                                             {
                                                                                                                 DisplayMode = RibbonDisplayMode.Menu16,
                                                                                                                 Controls = new List<RibbonControl>
                                                                                                                                {
                                                                                                                                    new RibbonFlyoutAnchor("Win", "Windows")
                                                                                                                                        {
                                                                                                                                            Title = "Windows",
                                                                                                                                            Sections = new List<RibbonMenuSection>
                                                                                                                                                           {
                                                                                                                                                               new RibbonMenuSection("Client", "Client")
                                                                                                                                                                {
                                                                                                                                                                    DisplayMode = RibbonDisplayMode.Menu16,
                                                                                                                                                                    Controls = new List<RibbonControl>
                                                                                                                                                                              {
                                                                                                                                                                                  new RibbonButton("1995", "Windows 95"){Image = ImageLibrary.GetStandardImage(0,1)},
                                                                                                                                                                                  new RibbonButton("1998", "Windows 98"){Image = ImageLibrary.GetStandardImage(0,2)},
                                                                                                                                                                                  new RibbonButton("2000c", "Windows Me"){Image = ImageLibrary.GetStandardImage(0,3)}
                                                                                                                                                                              }
                                                                                                                                                                },
                                                                                                                                                                new RibbonMenuSection("Server", "Server")
                                                                                                                                                                {
                                                                                                                                                                    DisplayMode = RibbonDisplayMode.Menu32,
                                                                                                                                                                    Controls = new List<RibbonControl>
                                                                                                                                                                              {
                                                                                                                                                                                  new RibbonButton("2000s", "Windows 2000 Server"){Image = ImageLibrary.GetStandardImage(0,4)},
                                                                                                                                                                                  new RibbonButton("2008", "Windows 2008"){Image = ImageLibrary.GetStandardImage(0,5)},
                                                                                                                                                                                  new RibbonButton("2012", "Windows 2012"){Image = ImageLibrary.GetStandardImage(0,6)}
                                                                                                                                                                              }
                                                                                                                                                                }
                                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                }
                                                                                                            }
                                                                              },
                                                                      }
                                                   }
                                           }
                            }
                          };
            ribbonAdapter.AddRibbonTabToPage(tab, Page, true);

        }
    }
}
